package HuaweiOD;

import java.util.HashSet;
import java.util.Scanner;

public class CPU算力分配 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int la = in.nextInt();
        int lb = in.nextInt();
        
        int[] A = new int[la];
        int sumA = 0;
        for (int i = 0; i < la; i++) {
            A[i] = in.nextInt();
            sumA+=A[i];
        }

        HashSet<Integer> B = new HashSet<>();
        int sumB = 0;
        for (int i = 0; i < lb; i++) {
            int b = in.nextInt();
            B.add(b);
            sumB += b;
        }

        int diff = (sumA - sumB) / 2;
        int minA = Integer.MAX_VALUE;
        String ans = "";
        for (int a : A) {
            int b = a - diff;
            if (B.contains(b)){
                minA = Math.min(minA, a);
                ans = a + " " + b;
            }
        }

        System.out.println(ans);
    }
}
